**************************************************************************
*THIS FILE MERGES TOGETHER ALL THE FILES NEEDED TO REPLICATE THE ANALYSES*
*Dependencies: kountry													 *
**************************************************************************


cd "INSERT DIRECTORY WHERE REPLICATION PACKAGE IS STORED"

use "Hollyer_Rosendorff_PTA_Update.dta", clear
sort ccode leadid year
drop _merge

*merge in fuel exports data from WDI
merge m:1 ccode year using "FuelExportsWDI.dta"
drop if _merge==2
drop _merge

*merge in fdi data from WDI
merge m:1 ccode year using "WDIFDI.dta"
drop if _merge==2
drop _merge

gen fdi1 = real(fdi)
drop fdi
rename fdi1 fdi

*merge in aid data from WDI
merge m:1 ccode year using "WDI Aid.dta"
drop if _merge==2
drop _merge

save "ReplicationTemp.dta", replace

*merge in Penn World Tables data
use "Penn World Tables 8.0_Prepped.dta", clear
kountry countrycode, from(iso3c) to(cown)
rename _COWN_ ccode
drop if ccode==.

merge 1:m ccode year using "ReplicationTemp.dta"
drop if _merge==1
drop _merge

save "ReplicationTemp.dta", replace

use "ReplicationTemp.dta", clear

*merge in Henisz political constraints index
merge m:1 ccode year using "polcon2012.dta"
drop if _merge==2
drop _merge

*merge in IMF data
merge m:1 ccode year using "HRVanalysisJOPPrepped.dta"
drop if _merge==2
drop _merge

*merge in polity data
merge m:1 ccode year using "Polity_2014.dta"
drop if _merge==2
drop _merge
replace polity=. if polity==-88
replace polity=. if polity==-77
replace polity=. if polity==-66

sort ccode leadid year


*create OECD indicator variable (1 implies global north country, 0 implies global south)
gen OECD=0

replace OECD=1 if ccode==900 & year>=1971
replace OECD=1 if ccode==305 & year>=1961
replace OECD=1 if ccode==211 & year>=1961
replace OECD=1 if ccode==20 & year>=1961
replace OECD=1 if ccode==155 & year>=2010
replace OECD=1 if ccode==316 & year>=1995
replace OECD=1 if ccode==390 & year>=1961
replace OECD=1 if ccode==366 & year>=2010
replace OECD=1 if ccode==375 & year>=1969
replace OECD=1 if ccode==220 & year>=1961
replace OECD=1 if ccode==255 & year>=1961
replace OECD=1 if ccode==350 & year>=1961
replace OECD=1 if ccode==310 & year>=1996
replace OECD=1 if ccode==395 & year>=1961
replace OECD=1 if ccode==205 & year>=1961
replace OECD=1 if ccode==666 & year>=2010
replace OECD=1 if ccode==325 & year>=1962
replace OECD=1 if ccode==740 & year>=1964
replace OECD=1 if ccode==732 & year>=1996
replace OECD=1 if ccode==212 & year>=1961
replace OECD=1 if ccode==70 & year>=1994
replace OECD=1 if ccode==210 & year>=1961
replace OECD=1 if ccode==920 & year>=1973
replace OECD=1 if ccode==385 & year>=1961
replace OECD=1 if ccode==290 & year>=1996
replace OECD=1 if ccode==235 & year>=1961
replace OECD=1 if ccode==317 & year>=2000
replace OECD=1 if ccode==349 & year>=2010
replace OECD=1 if ccode==230 & year>=1961
replace OECD=1 if ccode==380 & year>=1961
replace OECD=1 if ccode==225 & year>=1961
replace OECD=1 if ccode==640 & year>=1961
replace OECD=1 if ccode==200 & year>=1961
replace OECD=1 if ccode==2 & year>=1961


save "Replication.dta", replace
